package org.offsync.util

sealed abstract class Duration {
  def nanoseconds: Long
  
  def -(that: Duration): Duration
  
  def positiveTimeout: Long
}

object Forever extends Duration {
  def nanoseconds: Long = Long.MaxValue

  def -(that: Duration): Duration = Forever
  
  def positiveTimeout: Long = 0
}

case class DurationNanos(val nanoseconds: Long) extends Duration {
  def -(that: Duration): Duration = DurationNanos(nanoseconds - that.nanoseconds)

  def positiveTimeout: Long = nanoseconds
}
